
#include "Observer.h"
#include "ObserverA.h"
#include "ObserverB.h"
#include "ObserverCenter.h"
#include <iostream>

using namespace std;
using namespace npObserver;


void doObserver()
{
    shared_ptr<ObserverCenter> center = make_shared<ObserverCenter>();

    shared_ptr<Observer> david = make_shared<ObserverA>("David");
    shared_ptr<Observer> alice = make_shared<ObserverB>("Alice");

    center->insertObserver(weak_ptr<Observer>(david));
    center->insertObserver(weak_ptr<Observer>(alice));

    center->notify();

    cout << "remove a" << endl;
    center->removeObserver(weak_ptr<Observer>(david));

    center->notify();
}